import * as THREE from 'three'

export const handleMap3dData = MapData => {
  // const { baseMapAreas = [], baseMapData = {}, baseMapLocations = [], baseMapPaths = [], baseMapWords = [] } = MapData
  const { baseMapLocations = [], baseMapPaths = [] } = MapData
  const Points = baseMapLocations.map(el => ({ x: -el.positionX, y: 0, z: el.positionY, ...el })) || []
  const Lines = baseMapPaths.filter(s => !Number(s.isBezier)).map(el => {
    const [x1, y1, x2, y2] = el.allPoints
    return {
      start: [-x1, 0, y1],
      end: [-x2, 0, y2]
    }
  })
  const BezierLines = baseMapPaths.filter(s => !!Number(s.isBezier)).map(el => {
    const [x1, y1, x2, y2, x3, y3, x4, y4] = el.allPoints
    return {
      // start: [-x1, 0, y1],
      // control1: [-x2, 0, y2],
      // control2: [-x3, 0, y3],
      // end: [-x4, 0, y4],
      start: new THREE.Vector3(-x1, 0, y1),
      control1: new THREE.Vector3(-x2, 0, y2),
      control2: new THREE.Vector3(-x3, 0, y3),
      end: new THREE.Vector3(-x4, 0, y4),


    }
  })

  return { Points, Lines, BezierLines }
}
